<?php
/*
 * 根据品类id获取商品分类以及品类的小部件
 * Created by Zend Studio.
 * User: FDG348
 * Date: 2017/10/09
 * Time: 15:31
 */
namespace backend\widget;

use common\models\GoodsList;
use Yii;
use yii\base\Widget;

class DetailCrumbWidget extends Widget{

    public function run()
    {
        $data = Yii::$app->request->get();
        $crumb_list = array();
        if(!empty($data['goods_id']) && is_numeric($data['goods_id'])){
            $main_model = new GoodsList();
            $where = ['l.goods_id'=>$data['goods_id']];
            $crumb_list = $main_model::find()->alias('l')->where($where)->
            leftJoin('j_goods_category as c','l.category_step1 = c.id')->select('l.category_step1,goods_name_cn,tag_id,tag_name,c.category_name')->asArray()->one();
        }
        // 渲染视图
        return $this->render('@app/views/goods/detail-crumb', ['crumb_list'=>$crumb_list]);
    }
}